﻿using System;
using System.CodeDom.Compiler;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Threading;
using System.Web.Services;
using System.Web.Services.Description;
using System.Web.Services.Protocols;
using System.Xml.Serialization;

namespace AppEszköz.Log.Service
{
    [GeneratedCode("System.Web.Services", "4.0.30319.1")]
    [XmlInclude(typeof(object[]))]
    [DebuggerStepThrough]
    [DesignerCategory("code")]
    [WebServiceBinding(Name = "Service1Soap", Namespace = "http://Körülfon.com/")]
    public class LoggingService : SoapHttpClientProtocol
    {
        private SendOrPostCallback WriteLogOperationCompleted;
        private SendOrPostCallback SearchLogOperationCompleted;
        private SendOrPostCallback RetrieveApplicationsOperationCompleted;
        private bool useDefaultCredentialsSetExplicitly;

        public new string Url
        {
            get
            {
                return base.Url;
            }
            set
            {
                if (this.IsLocalFileSystemWebService(base.Url) && !this.useDefaultCredentialsSetExplicitly && !this.IsLocalFileSystemWebService(value))
                    base.UseDefaultCredentials = false;
                base.Url = value;
            }
        }

        public new bool UseDefaultCredentials
        {
            get
            {
                return base.UseDefaultCredentials;
            }
            set
            {
                base.UseDefaultCredentials = value;
                this.useDefaultCredentialsSetExplicitly = true;
            }
        }

        public event WriteLogCompletedEventHandler WriteLogCompleted;

        public event SearchLogCompletedEventHandler SearchLogCompleted;

        public event RetrieveApplicationsCompletedEventHandler RetrieveApplicationsCompleted;

        public LoggingService()
        {
            this.Url = "https://csddev.Körülfon.com/ApplicationLogging/LoggingService.asmx";
            if (this.IsLocalFileSystemWebService(this.Url))
            {
                this.UseDefaultCredentials = true;
                this.useDefaultCredentialsSetExplicitly = false;
            }
            else
                this.useDefaultCredentialsSetExplicitly = true;
        }

        [SoapDocumentMethod("http://firstmerit.com/WriteLog", ParameterStyle = SoapParameterStyle.Wrapped, RequestNamespace = "http://Körülfon.com/", ResponseNamespace = "http://Körülfon.com/", Use = SoapBindingUse.Literal)]
        public string WriteLog(int ApplicationID, EventTypes et, string EventDescription, string UserID, string URL, string IPAddress, object[] details)
        {
            return (string)this.Invoke("WriteLog", new object[7]
            {
        (object) ApplicationID,
        (object) et,
        (object) EventDescription,
        (object) UserID,
        (object) URL,
        (object) IPAddress,
        (object) details
            })[0];
        }

        public IAsyncResult BeginWriteLog(int ApplicationID, EventTypes et, string EventDescription, string UserID, string URL, string IPAddress, object[] details, AsyncCallback callback, object asyncState)
        {
            return this.BeginInvoke("WriteLog", new object[7]
            {
        (object) ApplicationID,
        (object) et,
        (object) EventDescription,
        (object) UserID,
        (object) URL,
        (object) IPAddress,
        (object) details
            }, callback, asyncState);
        }

        public string EndWriteLog(IAsyncResult asyncResult)
        {
            return (string)this.EndInvoke(asyncResult)[0];
        }

        public void WriteLogAsync(int ApplicationID, EventTypes et, string EventDescription, string UserID, string URL, string IPAddress, object[] details)
        {
            this.WriteLogAsync(ApplicationID, et, EventDescription, UserID, URL, IPAddress, details, (object)null);
        }

        public void WriteLogAsync(int ApplicationID, EventTypes et, string EventDescription, string UserID, string URL, string IPAddress, object[] details, object userState)
        {
            if (this.WriteLogOperationCompleted == null)
                this.WriteLogOperationCompleted = new SendOrPostCallback(this.OnWriteLogOperationCompleted);
            this.InvokeAsync("WriteLog", new object[7]
            {
        (object) ApplicationID,
        (object) et,
        (object) EventDescription,
        (object) UserID,
        (object) URL,
        (object) IPAddress,
        (object) details
            }, this.WriteLogOperationCompleted, userState);
        }

        private void OnWriteLogOperationCompleted(object arg)
        {
            if (this.WriteLogCompleted == null)
                return;
            InvokeCompletedEventArgs completedEventArgs = (InvokeCompletedEventArgs)arg;
            this.WriteLogCompleted((object)this, new WriteLogCompletedEventArgs(completedEventArgs.Results, completedEventArgs.Error, completedEventArgs.Cancelled, completedEventArgs.UserState));
        }

        [SoapDocumentMethod("http://Körülfon.com/SearchLog", ParameterStyle = SoapParameterStyle.Wrapped, RequestNamespace = "http://Körülfon.com/", ResponseNamespace = "http://Körülfon.com/", Use = SoapBindingUse.Literal)]
        public DataSet SearchLog(int ApplicationID, DateTime BeginDate, DateTime EndDate, int EventType, string EventDescription, string UserID, string URL, string IPAddress, int ResultLimit)
        {
            return (DataSet)this.Invoke("SearchLog", new object[9]
            {
        (object) ApplicationID,
        (object) BeginDate,
        (object) EndDate,
        (object) EventType,
        (object) EventDescription,
        (object) UserID,
        (object) URL,
        (object) IPAddress,
        (object) ResultLimit
            })[0];
        }

        public IAsyncResult BeginSearchLog(int ApplicationID, DateTime BeginDate, DateTime EndDate, int EventType, string EventDescription, string UserID, string URL, string IPAddress, int ResultLimit, AsyncCallback callback, object asyncState)
        {
            return this.BeginInvoke("SearchLog", new object[9]
            {
        (object) ApplicationID,
        (object) BeginDate,
        (object) EndDate,
        (object) EventType,
        (object) EventDescription,
        (object) UserID,
        (object) URL,
        (object) IPAddress,
        (object) ResultLimit
            }, callback, asyncState);
        }

        public DataSet EndSearchLog(IAsyncResult asyncResult)
        {
            return (DataSet)this.EndInvoke(asyncResult)[0];
        }

        public void SearchLogAsync(int ApplicationID, DateTime BeginDate, DateTime EndDate, int EventType, string EventDescription, string UserID, string URL, string IPAddress, int ResultLimit)
        {
            this.SearchLogAsync(ApplicationID, BeginDate, EndDate, EventType, EventDescription, UserID, URL, IPAddress, ResultLimit, (object)null);
        }

        public void SearchLogAsync(int ApplicationID, DateTime BeginDate, DateTime EndDate, int EventType, string EventDescription, string UserID, string URL, string IPAddress, int ResultLimit, object userState)
        {
            if (this.SearchLogOperationCompleted == null)
                this.SearchLogOperationCompleted = new SendOrPostCallback(this.OnSearchLogOperationCompleted);
            this.InvokeAsync("SearchLog", new object[9]
            {
        (object) ApplicationID,
        (object) BeginDate,
        (object) EndDate,
        (object) EventType,
        (object) EventDescription,
        (object) UserID,
        (object) URL,
        (object) IPAddress,
        (object) ResultLimit
            }, this.SearchLogOperationCompleted, userState);
        }

        private void OnSearchLogOperationCompleted(object arg)
        {
            if (this.SearchLogCompleted == null)
                return;
            InvokeCompletedEventArgs completedEventArgs = (InvokeCompletedEventArgs)arg;
            this.SearchLogCompleted((object)this, new SearchLogCompletedEventArgs(completedEventArgs.Results, completedEventArgs.Error, completedEventArgs.Cancelled, completedEventArgs.UserState));
        }

        [SoapDocumentMethod("http://Körülfon.com/RetrieveApplications", ParameterStyle = SoapParameterStyle.Wrapped, RequestNamespace = "http://Körülfon.com/", ResponseNamespace = "http://Körülfon.com/", Use = SoapBindingUse.Literal)]
        public DataSet RetrieveApplications()
        {
            return (DataSet)this.Invoke("RetrieveApplications", new object[0])[0];
        }

        public IAsyncResult BeginRetrieveApplications(AsyncCallback callback, object asyncState)
        {
            return this.BeginInvoke("RetrieveApplications", new object[0], callback, asyncState);
        }

        public DataSet EndRetrieveApplications(IAsyncResult asyncResult)
        {
            return (DataSet)this.EndInvoke(asyncResult)[0];
        }

        public void RetrieveApplicationsAsync()
        {
            this.RetrieveApplicationsAsync((object)null);
        }

        public void RetrieveApplicationsAsync(object userState)
        {
            if (this.RetrieveApplicationsOperationCompleted == null)
                this.RetrieveApplicationsOperationCompleted = new SendOrPostCallback(this.OnRetrieveApplicationsOperationCompleted);
            this.InvokeAsync("RetrieveApplications", new object[0], this.RetrieveApplicationsOperationCompleted, userState);
        }

        private void OnRetrieveApplicationsOperationCompleted(object arg)
        {
            if (this.RetrieveApplicationsCompleted == null)
                return;
            InvokeCompletedEventArgs completedEventArgs = (InvokeCompletedEventArgs)arg;
            this.RetrieveApplicationsCompleted((object)this, new RetrieveApplicationsCompletedEventArgs(completedEventArgs.Results, completedEventArgs.Error, completedEventArgs.Cancelled, completedEventArgs.UserState));
        }

        public new void CancelAsync(object userState)
        {
            base.CancelAsync(userState);
        }

        private bool IsLocalFileSystemWebService(string url)
        {
            if (string.IsNullOrEmpty(url))
                return false;
            Uri uri = new Uri(url);
            return uri.Port >= 1024 && string.Compare(uri.Host, "localHost", StringComparison.OrdinalIgnoreCase) == 0;
        }
    }
}
